var path = require('path');
var gui = require('nw.gui');
var win = gui.Window.get();
//全屏启动

win.maximize();
win.enterKioskMode()

var isFullscreen = true;

var isPlaying = false;
function processKey($event) {
    switch ($event.charCode) {
        case 13:
            // if (isPlaying) {
            nextStep()
            // }
            // else {
            //     var mainVideo = document.getElementById('mainVideo');
            //     mainVideo.play();
            //     isPlaying=true;
            // }
            break;
        case 114:
            reSet()
            break;
        case 102:
            win.toggleKioskMode()
    }
}
var zoomLevel = 0;
function setShotcut() {
    var optionPlus = {
        key: "Ctrl+=",
        active: function () {
            console.log("Global desktop keyboard shortcut: " + this.key + " active.");
            win.zoomLevel += 1;
        },
        failed: function (msg) {
            // :(, fail to register the |key| or couldn't parse the |key|.
            console.log(msg);
        }
    };

    // Create a shortcut with |option|.
    var shortcutPlus = new nw.Shortcut(optionPlus);

    var optionMinus = {
        key: "Ctrl+-",
        active: function () {

            console.log("Global desktop keyboard shortcut: " + this.key + " active.");
            win.zoomLevel -= 1;
        },
        failed: function (msg) {
            // :(, fail to register the |key| or couldn't parse the |key|.
            console.log(msg);
        }
    };

    // Create a shortcut with |option|.
    var shortcutMinus = new nw.Shortcut(optionMinus);

    // Register global desktop shortcut, which can work without focus.
    nw.App.registerGlobalHotKey(shortcutPlus);
    nw.App.registerGlobalHotKey(shortcutMinus);
}
setShotcut();

function init() {
    var path = require('path');
    console.log(path.resolve(process.execPath))
    loadData()
    win.enterKioskMode()

}

function loadAnimation() {
    var list = lotteryData.items.slice(100).map(function (d) {
        var size = 10 + Math.random() * 90
        return [d, size]
    });
    window.addEventListener('wordclouddrawn', data => {
        console.log(data.detail)
    })
    window.addEventListener('wordcloudstop', data => {
        console.log(data.detail)
        // canvasEffect(renderCanvasArr)
    })
    WordCloud([document.getElementById('wrapCanvas')], {
        list: list,
        rotateRatio: 0.5,
        rotationSteps: 2,
        color: 'black'
    });
}